home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8570 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: nntp.uib.no!usenet
  2. From: ketil@ii.uib.no (Ketil Z Malde)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Overloading operator [][] as in A[][]: possible?!
  5. Date: 14 Feb 1996 16:35:00 +0100
  6. Organization: II, UiB
  7. Sender: ketil@haukugle.ii.uib.no
  8. Message-ID: <eg68d9apjv.fsf@haukugle.ii.uib.no>
  9. References: <311F6E92.794BDF32@cenparmi.concordia.ca>
  10. Reply-To: ketil@ii.uib.no
  11. NNTP-Posting-Host: haukugle.ii.uib.no
  12. X-Newsreader: September Gnus v0.38/XEmacs 19.13
  13.  
  14. >>>>> "D" == Didier Guillevic <didier@cenparmi.concordia.ca> writes:
  15.  
  16.     D> Learning C++ at the moment....  
  17.  
  18. Me too
  19.  
  20.     D> Any way to overload
  21.     D> the indexing of a 2 dimensional array, as in
  22.  
  23.     D>   A[i][j]
  24.  
  25. This means an array of j pointers to i As, remember?  I guess you
  26. *could* overload the [] operator for A, and then again for A*, but I
  27. haven't seen it done.
  28.  
  29. Using the double-[] semantics for two-dim arrays is a mess (IMHO).
  30.  
  31.     D> If possible, I would prefer to avoid using a notation such as:
  32.  
  33.     D>   A(i,j)
  34.  
  35. Me too
  36.  
  37. I don't like that either, but it seems to be the de facto standard way
  38. of doing things.  I'd really like to be able to oveload [] to take
  39. more than one argument, but apparently I can't -- at least not
  40. without overloading the , operator as well.  I guess we're stuck with
  41. what looks like a constructor.
  42.  
  43. I'm sure this has come up in the discussion about changes to C++, if
  44. somebody can enlighten me why the multi-argument [] was turned down,
  45. I'd be grateful.
  46.  
  47. -kzm
  48.  
  49.  
  50.